home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / c_lang / varinc.lzh / PAGE50B.C < prev    next >
Text File  |  1979-11-30  |  987b  |  17 lines

  1. /* Loop until a nonspace character (may be null) is found. */
  2.  
  3. for (last_space = 0; text[last_space] == ' '; ++last_space)
  4.    ;                                         /* null statement for loop body */
  5.  
  6. /* strlen() returns the index of text's null character. */
  7. len_text = strlen(text);                       /* Get string length of text. */
  8.  
  9. /* Loop: move characters back to replace leading spaces. Notice the use */
  10. /*   of the comma operator to perform two initializations and two step  */
  11. /*   expressions in each loop.                                          */
  12. for (from_pos = last_space, to_pos = 0;                  /* loop initializer */
  13.    from_pos <= len_text;                                        /* loop test */
  14.    ++from_pos, ++to_pos)                                        /* loop step */
  15.       text[to_pos] = text[from_pos];                            /* loop body */
  16. text[to_pos] = '\0';                           /* new end of string for text */
  17.